import QtQuick
import QtQuick.Controls

Rectangle {
    width: 400
    height: 400

    property var framePaths: [
        "qrc:/images/skill/1.png",
        "qrc:/images/skill/2.png",
        "qrc:/images/skill/3.png",
        "qrc:/images/skill/4.png",
        "qrc:/images/skill/5.png",
        "qrc:/images/skill/6.png",
        "qrc:/images/skill/7.png",
        "qrc:/images/skill/8.png",
        "qrc:/images/skill/9.png",
        "qrc:/images/skill/10.png",
        "qrc:/images/skill/11.png",
        "qrc:/images/skill/12.png",
        "qrc:/images/skill/13.png",
        "qrc:/images/skill/14.png",
        "qrc:/images/skill/15.png",
        "qrc:/images/skill/16.png"
    ]

    Item {
        id: scene
        anchors.fill: parent

        // 精灵显示
        Image {
            id: spriteDisplay
            width: 350
            height: 350
            anchors.centerIn: parent
            source: framePaths[0]
        }

        // 动画控制
        property int currentFrame: 0
        property bool isPlaying: false

        Timer {
            id: animationTimer
            interval: 100
            running: scene.isPlaying
            repeat: true
            onTriggered: {
                scene.currentFrame = (scene.currentFrame + 1) % framePaths.length;
                spriteDisplay.source = framePaths[scene.currentFrame];
            }
        }
    }

    Column {
        anchors.right: parent.right
        anchors.bottom: parent.bottom
        spacing: 10
        padding: 10

        Button {
            text: scene.isPlaying ? "暂停" : "播放"
            onClicked: scene.isPlaying = !scene.isPlaying
        }
    }
}
